import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import operate from '@dfeidao/atom-nodejs/db/operate';
import { systemid, productid } from '../../atom/config';
import doc_code from '@dfeidao/atom-nodejs/msg/doc-code';
interface Message {
	post_package_name: string,
	plan_cla_attr_name: string,
	plan_type_name: string,
	plan_type_no: string,
	plan_cla_attr_no: string
}

// interface IWebResult {
// 	data: unknown;
// 	cookie?: {
// 		[name: string]: string;
// 	} | null;
// 	content_type?: string;
// 	headers?: {
// 		[key: string]: string[];
// 	};
// 	attachment?: string;
// 	redirect?: string;
// 	status_code?: number;
// }

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	const res1 = await doc_code(action_id, session_id, systemid, 'BM0014358', '', 1);
	const { exec, insert, } = operate(action_id, session_id, systemid);
	// 插入数据
	insert('post_package', { productid, post_package: res1.result, post_package_name: message.post_package_name, plan_cla_attr_name: message.plan_cla_attr_name, plan_type_name: message.plan_type_name, plan_type_no: message.plan_type_no, plan_cla_attr_no: message.plan_cla_attr_no });
	const ret = await exec();
	return {
		data: ret
	}
}
